local key = KEYS[1]
local window = tonumber(ARGV[1])
local threshold = tonumber(ARGV[2])

local current = tonumber(redis.call('GET', key) or 0)
if current >= threshold then
    return 0
end

redis.call('INCR', key)
if current == 0 then
    redis.call('EXPIRE', key, window)
end
return 1